﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using HNCDataSetTableAdapters;

public partial class UserControl_content_contact : System.Web.UI.UserControl
{
    InfoTableAdapter info = new InfoTableAdapter();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ltrMap.Text = loadMap();
        }
    }

    public string loadMap()
    {
        string tem = "";
        DataTable dt = info.GetInfoByID(1);
        lblTitle.Text = dt.Rows[0]["Title"].ToString();
        lblAddress.Text = dt.Rows[0]["Address"].ToString();
        lblEmail.Text = dt.Rows[0]["Email"].ToString();
        lblWevsite.Text = dt.Rows[0]["Address_en"].ToString();
        string GoogleMap = dt.Rows[0]["GoogleMap"].ToString();
        tem += "<iframe width=\"580\" height=\"580\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"";
        tem += GoogleMap;
        tem += "\"></iframe><br /><small><a href=\"";
        tem += GoogleMap;
        tem += "\" style=\"color: #0000FF; text-align: left\">Xem Bản đồ cỡ lớn hơn</a></small>";
        return tem;
    }

    protected void btnSend_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            DataTable dt = info.GetInfoByID(1);
            string mailto = dt.Rows[0]["Email"].ToString();

            #region nội dung thu liên hệ

            string temp = @"<table align='center' cellpadding='0' cellspacing='0'  style='color: #666666; font-size: small; font-family: Arial, Helvetica, sans-serif;' width='720'>    

    <tr>
        <td align='left' colspan='2' height='50' class='auto-style5'>
            Thông tin liên hệ</td>
    </tr>
    <tr>
        <td align='left' 
            style='border-bottom: 1px dashed #CCCCCC; text-align: right; border-left-color: #CCCCCC; border-right-color: #CCCCCC; border-top-color: #CCCCCC; padding-right: 10px;' 
            width='150'>
            Họ và tên</td>
        <td align='left' 
            style='border-color: #CCCCCC; padding: 3px; border-bottom-style: dashed; border-bottom-width: 1px; text-align: left;' class='auto-style3'>
            " + txtName.Text + @"</td>
    </tr>
 
    <tr>
        <td align='left' 
            style='border-bottom: 1px dashed #CCCCCC; text-align: right; border-left-color: #CCCCCC; border-right-color: #CCCCCC; border-top-color: #CCCCCC; padding-right: 10px;' 
            width='150'>
            Điện thoại</td>
        <td align='left' 
            style='border-color: #CCCCCC; padding: 3px; border-bottom-style: dashed; border-bottom-width: 1px; text-align: left;' class='auto-style3'>
            " + txtPhone.Text + @"</td>
    </tr>
    <tr>
        <td align='left' 
            style='border-bottom: 1px dashed #CCCCCC; text-align: right; border-left-color: #CCCCCC; border-right-color: #CCCCCC; border-top-color: #CCCCCC; padding-right: 10px;' 
            width='150'>
            Địa chỉ</td>
        <td align='left'
            style='border-color: #CCCCCC; padding: 3px; border-bottom-style: dashed; border-bottom-width: 1px; text-align: left;'>
            " + txtAddress.Text + @"</td>
    </tr>
    <tr>
        <td align='left' 
            style='border-bottom: 1px dashed #CCCCCC; text-align: right; border-left-color: #CCCCCC; border-right-color: #CCCCCC; border-top-color: #CCCCCC; padding-right: 10px;' 
            width='150'>
            E-mail</td>
        <td align='left'
            style='border-color: #CCCCCC; padding: 3px; border-bottom-style: dashed; border-bottom-width: 1px; text-align: left;' class='auto-style3'>
            " + txtEmail.Text + @"</td>
    </tr>

    <tr>
        <td align='left' 
            style='border-bottom: 1px dashed #CCCCCC; text-align: right; border-left-color: #CCCCCC; border-right-color: #CCCCCC; border-top-color: #CCCCCC; padding-right: 10px;' 
            width='150'>
            Tiêu đề</td>
        <td align='left' 
            style='border-color: #CCCCCC; padding: 3px; border-bottom-style: dashed; border-bottom-width: 1px; text-align: left;'>
            " + txtTitle.Text + @"</td>
    </tr>
   
    <tr>
        <td align='left' 
            style='border-bottom: 1px dashed #CCCCCC; text-align: right; border-left-color: #CCCCCC; border-right-color: #CCCCCC; border-top-color: #CCCCCC; padding-right: 10px;' 
            width='150'>
            Nội Dung Liên Hệ</td>
        <td align='left' 
            style='border-color: #CCCCCC; padding: 3px; border-bottom-style: dashed; border-bottom-width: 1px; text-align: left;'>
            " + txtContent.Text + @"</td>
    </tr>
    </table>";
            #endregion

            FuntionHNC.sendmail(txtEmail.Text, mailto, txtEmail.Text, txtTitle.Text, temp);

            txtName.Text = "";
            txtAddress.Text = "";
            txtPhone.Text = "";
            txtEmail.Text = "";
            txtContent.Text = "";


            lblMsg.Text = "Đã gởi thông tin liên hệ.<br/> Chúng tôi sẽ liên hệ đến bạn trong thời gian sớm nhất.";

        }
        catch (Exception)
        {

            return;
        }
        #endregion
    }

}